/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __PQ_Logger_H__
#define __PQ_Logger_H__

#include <stdio.h>

namespace PQCore
{
	/*This class used log info to file or db
	*/
	class Logger
	{
	protected:
		Logger();
	public:
		static Logger &getSingleton()
		{
			static Logger inst;
			return inst;
		}

		FILE* open(char const* name,char const* flag, char const* mode);
		
		void logError(const char * err, ...);
		void log(const char * str, ...);
		void logDebug(const char * str, ...);

		void outBasic(const char * str, ...);
		void outDetail(const char * str, ...);
		void outErrorDb(const char * str, ...);
		void outDB();
		void outLine();
		void outTimestamp(FILE* file);

	private:
		FILE* _file;
	};

}

#define PQLogger PQCore::Logger::getSingleton()

#ifdef PROGRAM_DEBUG
#define DEBUG_LOG PQLogger.logDebug
#else
#define DEBUG_LOG
#endif

#endif
